#ifndef NETWORK_H
#define NETWORK_H
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <arpa/inet.h>
typedef enum {TCPServer,TCPClient,UDPSender,UDPRecver} Role;

typedef struct NetWork
{
	int sockfd;
	int type;
	bool role;	
	struct sockaddr_in addr;
	socklen_t addrlen;
}NetWork;

typedef struct sockaddr* SAP;

NetWork* open_nw(int type,uint16_t port,const char* ip,bool role);

NetWork* accept_nw(NetWork* nw);

int send_nw(NetWork* nw,void* buf,size_t len);

int recv_nw(NetWork* nw,void* buf,size_t len);

int close_nw(NetWork* nw);

const char* getip_nw(NetWork* nw);

#endif//NETWORK_H
